package com.secondshop.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.secondshop.models.Address;

import com.secondshop.mappers.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
public class AddressService {

	@Autowired
	private AddressMapper addressMapper;
	
	  private Page<Address> l ;
	  
	  public Page<Address> getL() { return l; }
	  
	  public void setL(Page<Address> l) { this.l = l; }
	 


//	public Address getAddress(Long addressId) {
//		Address osAddress = AddressMapper.selectByAddressId(addressId);
//		return osAddress;
//	}

//	
//	  //分页查询收货地址
//	public List<Address> pageAddressInfo(Integer page, Integer limit,
//	  Long userId) { 
//		PageHelper.startPage(page, limit);
//		List<Address> list =AddressMapper.selectByUserId(userId); 
//		this. l = (Page<Address>)list; return
//	  list; }
//	 
	  //查询收货地址
	  @Transactional
	public List<Address> listAddress(int userId) {
		List<Address> list = addressMapper.selectByUserId(userId);
		return list;
	}

	// 新增收货地址
	@Transactional
	public int insertAddress(Address Address) {
		int count = addressMapper.insert(Address);
		return count;
	}

//	// 更新收货地址
//	public int updatetAddress(Address Address) {
//		int count = AddressMapper.updateByPrimaryKeySelective(Address);
//		return count;
//	}
//
//	// 删除收货地址
//	public int deleteByAddressId(Long addressId) {
//		int count = AddressMapper.deleteByPrimaryKey(addressId);
//		return count;
//	}
}